<template>
    <div>
        <el-row class="row-with-margin">
            <el-col :span="24">
                <div>
                    <el-button>导出</el-button>
                    <el-button>导入</el-button>
                </div>
            </el-col>
        </el-row>


        <el-row class="row-with-margin">
            <el-col :span="24">
                <el-form :inline="true">
                    <el-form-item label="结算状态">
                        <el-select clearable placeholder="请选择订单状态" v-model="param.settlementStatus">
                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" >
                        </el-option>
                    </el-select>
                    </el-form-item>

                    <el-form-item label="结算日期">
                        <el-date-picker type="daterange" range-separator="至" start-placeholder="开始日期"
                            end-placeholder="结束日期" v-model="param.betweenTime">
                        </el-date-picker>
                    </el-form-item>

                    <el-form-item label="客户名称：" label-width="100px">
                        <el-input placeholder="请输入关键词搜索" style="width: 200px; margin-left: 10px;" v-model="param.customerName"></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary" @click="queryAll2">查询</el-button>
                        <el-button style="margin-left: 10px;">重置</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>

        <!-- 表格部分------------------------------------------------------------------------------------------------------ -->
        <el-row>
            <el-col :span="24">
                <div>
                    <el-table :data="tableData" style="width: 100%; margin-top: 20px;">
                        <el-table-column type="selection" width="55"></el-table-column>
                        <el-table-column prop="receivableId" label="对账单号" width="180"></el-table-column>
                        <el-table-column prop="customerName" label="客户名称" width="180"></el-table-column>
                        <el-table-column  label="结算状态" width="180">
                            <template v-slot="scope">
                                <span v-if="scope.row.settlementStatus == 0">未结算</span>
                                <span v-else-if="scope.row.settlementStatus == 1">已结算</span>
                                <span v-else>未知类型</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="goodsCount" label="货物数量" width="180"></el-table-column>
                        <el-table-column prop="goodsVolume" label="货物总体积" width="180"></el-table-column>
                        <el-table-column prop="goodsWeight" label="货物总重量" width="180"></el-table-column>
                        <el-table-column prop="powerUserName" label="创建人" width="180"></el-table-column>
                        <el-table-column prop="createdTime" label="创建时间" width="180"></el-table-column>
                        <!-- <el-table-column label="操作" width="180">
                            <el-button type="text" size="medium">编辑</el-button>
                            <el-button type="text" size="medium">删除</el-button>
                        </el-table-column> -->
                    </el-table>
                </div>
            </el-col>
        </el-row>


        <el-row>
            <el-col :span="24">
                <el-pagination background :page-sizes="[1, 10, 20, 30, 50]" :page-size="pageSize"
                    :current-page="pageNum" :total="total" layout="total,sizes,prev, pager, next,jumper">
                </el-pagination>
            </el-col>
        </el-row>


    </div>
</template>

<script>
export default {
    data() {
        return {
            pageSize: 10,
            pageNum: 1,
            total: 0,
            options: [{ value: '0', label: '未结算' },
            { value: '1', label: '已结算' },], //订单状态下拉框
            value: '',//订单状态下拉框赋值
            tableData: [],//表格对象
            param:{},
        }
    },

    methods: {
        queryAll2(){
            let pageParam = {};
            pageParam.pageNum = this.pageNum;
            pageParam.pageSize = this.pageSize;
            pageParam.param = this.param;
            this.$axios.post('api/receivable/queryAll2', pageParam)
                .then(resp => {
                    console.log(resp.data);
                    if (resp.data.code === 200) {
                        this.tableData = resp.data.data.list
                        this.total = resp.data.data.total
                    }

                })
                .catch(error => {
                    console.error('操作失败:', error);
                    this.$message.error('网络请求失败，请稍后再试');
                });
        }
    },
    created(){
        this.queryAll2()
    }
}
</script>

<style scoped>
.row-with-margin {
    margin-bottom: 20px;
    /* 根据需要调整间隙大小 */
}
</style>